package com.example.flowable.service;

import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.Process;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;

import java.io.FileNotFoundException;
import java.util.List;
import java.util.Map;

/**
 * @Classname FlowableService
 * @Description TODO
 * @Date 2022/8/10 20:10
 * @Created by XiongXiong
 * @Author: X.I.O
 */
public interface FlowableService {

    public void deployment() throws FileNotFoundException;

    /**
     * 通过文件路径部署流程
     * @param file
     * @throws FileNotFoundException
     */
    public Deployment deploymentByFile(String file) throws FileNotFoundException;

    /**
     * 通过部署的流程id 获取流程版本
     * @param deployId  部署的流程id
     * @return  流程版本
     */
    public ProcessDefinition getProcessDefinitionByDeployId(String deployId);

    /**
     * 创建流程
     * @param deployId 部署的流程版本id
     * @param title    标题
     * @param uid      用户id
     * @param object   流程变量
     * @return
     */
    public ProcessInstance createProcessInstance(String deployId, String title, String uid, Map<String,Object> object);

    /**
     * 通过部署id 获取所有节点信息
     * @return
     */
    public List<Process> getProcessListByDeployId(String deployId);


    /**
     * 提交任务
     * @param taskId 任务id
     * @param uid    下个任务节点的用户
     * @param msg     审核信息
     */
    public void submitTask(String taskId,String uid,String msg);


    /**
     * 通过流程id获取任务列表
     * @param processInstanceId
     * @return
     */
    public List<Task> getTaskListByProcessInstanceId(String processInstanceId);

    /**
     * 处理网关
     * @param flowElement
     * @param data
     */
    public void dealGetWay(FlowElement flowElement, Map data);


    /**
     *
     * @param processId      流程
     * @param currentNodeId  当前节点
     *
     *
     * @param nodeId         节点
     */
    public void changeProcessInstancsNode(String processId,String currentNodeId,String nodeId);


    /**
     * 通过流程id获取流程
     * @param processInstanceId
     * @return
     */
    public ProcessInstance getProcessInstanceById(String processInstanceId);


    /**
     * 获取所有节点
     * @param processId 流程id
     * @param objects 对象
     * @return
     */
    List<FlowElement> getAllNodesByProcessId(String processId,Map<String,Object> objects);

}
